package com.neusoft.neuiotms.dcvm.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractModel;
import com.neusoft.bizcore.web.jpa.model.Comment;
import com.neusoft.neuiotms.dcvm.enums.SysTaskStatus;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@ToString
@Entity
@org.hibernate.annotations.Table(appliesTo = "neuiot_sys_task", comment = "定时任务设置")
@Table(name = "neuiot_sys_task")
public class SysTask extends AbstractModel {

    private static final long serialVersionUID = 1L;

    @NotBlank(message = "名称不能为空")
    @Length(max = 255, message = "名称不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '名称'")
    private String name;

    @NotBlank(message = "code不能为空")
    @Length(max = 255, message = "code不能超过{max}位")
    @Column(length = 255, nullable = false, unique = true)
    @Comment("varchar(255) NOT NULL COMMENT '编码'")
    private String code;

    @NotBlank(message = "cron表达式不能为空")
    @Length(max = 255, message = "cron表达式不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT 'cron'")
    private String cron;

    @Enumerated(EnumType.STRING)
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) COMMENT '状态'")
    private SysTaskStatus status = SysTaskStatus.active;

    @NotBlank(message = "类名不能为空")
    @Length(max = 1023, message = "类名不能超过{max}位")
    @Column(length = 1023, nullable = false)
    @Comment("varchar(1023) NOT NULL COMMENT '定时任务执行类名'")
    private String jobClass;

    @Length(max = 255, message = "定时任务组名不能超过{max}位")
    @Column(length = 255, nullable = true)
    @Comment("varchar(1023) COMMENT '定时任务组名'")
    private String jobGroup;

    @Length(max = 1023, message = "描述不能超过{max}位")
    @Column(length = 1023, nullable = true)
    @Comment("varchar(1023) COMMENT '定时任务描述'")
    private String jobDesc;

    @Lob
    @Column(columnDefinition = "longtext")
    @Comment("longtext COMMENT 'jobData'")
    private String jobData;

}
